#ifndef _TRAPEZOIDAL_H
#define _TRAPEZOIDAL_H

#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>

#include "fns.h"

/* Funtion for calulating integral by using trapezoidal rule */
double trapezoidal (FnP fnPtr, double lo_bound, double hi_bound, int n_intervals);

/* To find the integration accurately split the intervals of the integration into n intervals and find out summation of it.
   And then apply trapeziodal rule on it */
double calc_sum (FnP fnPtr, double lo_bound, double hi_bound, int n_intervals);

/* This will check if the given function is available*/
int isFunAvailable (char *strPtr);
/* Pass 0/1 as 2nd argument to checkNum funtion to check if it is double or not */
int checkNum (char *strPtr, int isDouble);

void createProcessTree(int *childProcesses, int childIndex, int level, int debug);

void getData (int **parentInFD, int **parentRtFD, int children, int level, int debug);
void integration (int children, int level, int debug);

typedef struct Params{
	char *fnName;
	double lo_bound;
	double hi_bound;
	int n_intervals;
	int error;
}Params;

#endif /* end of _TRAPEZOIDAL_H */
